<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery" >
        <a-row :gutter="24" style="padding-top: 30px">
          <a-col :md="6" :sm="8">
            <a-form-item label="订单号">
              <a-input placeholder="订单号" v-model="queryParam.ipoNo"  :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }"></a-input>
            </a-form-item>
           
          </a-col>
          <a-col :md="18" :sm="16"  >
            <span  class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
             <a-button type="primary" @click="showOrClose" icon="search"  style='margin-left: 10px;'>高级查询</a-button>
              <a-button type="primary" icon="download" @click="handleExportXls('eip_work_order')"  style='margin-left: 10px;'>导出</a-button>
            </span>
          </a-col>
        </a-row>
        </a-form>
         </div>
        <a-row v-if="show">
         
            <a-col :md="6" :sm="8">
              <a-form-item label="母单号"  :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
                <a-input placeholder="母单号" v-model="queryParam.pIpoNo" ></a-input>
              </a-form-item>
            </a-col>
           
          <a-col :md="6" :sm="8">
            <a-form-item label="物料名称" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
              <a-input placeholder="物料名称" v-model="queryParam.materialsName" ></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8" >
            <a-form-item label="产品编号"  :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
              <a-input placeholder="产品编号" v-model="queryParam.productModel" ></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="销售订单号" :label-col="{ span: 6}" :wrapper-col="{ span: 15}">
              <a-input placeholder="销售订单号" v-model="queryParam.poItemId" ></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="计划开始日期"  :label-col="{ span: 6}" :wrapper-col="{ span: 15}">
               <a-date-picker v-model="queryParam.planStartDate"/>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="计划完成时间" :label-col="{ span: 6}" :wrapper-col="{ span: 15}">
              <a-date-picker v-model="queryParam.planFinishDate"/>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8" >
            <a-form-item label="采购订单行项目id" :label-col="{ span: 8}" :wrapper-col="{ span: 13}" >
              <a-input placeholder="采购订单行项目id" v-model="queryParam.poItemId" ></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8" >
            <a-form-item label="组织架构" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
               <a-select
                   v-model="value"
                   mode="multiple"
                   style="width: 100%"
                   placeholder="select one country"
                   option-label-prop="label"
                 >
                   <a-select-option value="平高电器" label="平高电器">
                      平高电器
                   </a-select-option>
                   <a-select-option value="组合电器" label="组合电器">
                     <span role="img" aria-label="组合电器">
                       平高
                     </span>
                     组合电器
                   </a-select-option>
                   <a-select-option value="断路器" label="断路器">
                     <span role="img" aria-label="断路器">
                       平高
                     </span>
                    断路器
                   </a-select-option>
                   <a-select-option value="平芝" label="平芝">
                     平芝
                   </a-select-option>
                 </a-select>
            </a-form-item>
          </a-col>
        </a-row>
     

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="puid"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
        
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="图片不存在" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
           <a-divider type="vertical" />
          <a @click="toGd(record)">关联生产工单</a>
          <a @click="handleEdit(record)">编辑</a>

          <!--<a-divider type="vertical" />-->
          <!--<a-dropdown>-->
            <!--<a class="ant-dropdown-link">更多 <a-icon type="down" /></a>-->
            <!--<a-menu slot="overlay">-->
              <!--<a-menu-item>-->
                <!--<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
                  <!--<a>删除</a>-->
                <!--</a-popconfirm>-->
              <!--</a-menu-item>-->
            <!--</a-menu>-->
          <!--</a-dropdown>-->
        </span>

      </a-table>
    </div>

    <eipProductionOrder-modal ref="modalForm" @ok="modalFormOk"></eipProductionOrder-modal>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import EipProductionOrderModal from './modules/EipProductionOrderModal'
  import ACol from 'ant-design-vue/es/grid/Col'
  export default {
    name: "EipProductionOrderList",
    mixins:[JeecgListMixin],
    components: {
      ACol,
      EipProductionOrderModal
    },
    data () {
      return {
        description: 'eip_production_order管理页面',
        show:false,
        orgName1:"",
        orgName2:"",
        org1:"",
        org2:"",
        value: ['平高电器'],
        // 表头
        columns: [
          {
            title:'供应商编码',
            align:"center",
            dataIndex: 'supplierCode'
          },
          {
            title:'供应商名称',
            align:"center",
            dataIndex: 'supplierName'
          },
          {
            title:'生产订单号',
            align:"center",
            dataIndex: 'ipoNo'
          },
          {
            title:'母单号',
            align:"center",
            dataIndex: 'pIpoNo'
          },
          {
            title:'采购订单行项目id',
            align:"center",
            dataIndex: 'poItemId'
          },
          {
            title:'种类编码',
            align:"center",
            dataIndex: 'subclassCode'
          },
          {
            title:'厂家物料编码',
            align:"center",
            dataIndex: 'materialsCode'
          },
          {
            title:'厂家物料名称',
            align:"center",
            dataIndex: 'materialsName'
          },
          {
            title:'厂家物资单位',
            align:"center",
            dataIndex: 'materialsUnit'
          },
          {
            title:'生产数量',
            align:"center",
            dataIndex: 'amount'
          },
          {
            title:'产品型号',
            align:"center",
            dataIndex: 'productModel'
          },
          {
            title:'计划开始日期',
            align:"center",
            dataIndex: 'planStartDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'计划完成日期',
            align:"center",
            dataIndex: 'planFinishDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'实际开始日期',
            align:"center",
            dataIndex: 'actualStartDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'实际完成日期',
            align:"center",
            dataIndex: 'actualFinishDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'生产订单状态',
            align:"center",
            dataIndex: 'ipoStatus'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/eipProductionOrder/selectForList?poItemId="+this.$route.params.poItemId,
          // delete: "/pg/eipProductionOrder/delete",
          // deleteBatch: "/pg/eipProductionOrder/deleteBatch",
          exportXlsUrl: "/eipProductionOrder/exportXls",
          // importExcelUrl: "/eipProductionOrder/importExcel",
        },
        dictOptions:{
        } 
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      initDictConfig(){
      },
      showOrClose(){
        this.show = !this.show;
      },
      toGd(record){
        this.$router.push({ name: 'gdList',params:{ipoNo:record.ipoNo}})
      }
    },
    watch: {
       value(val) {
         console.log(`selected:`, val);
       },
     },
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>